<?php
/**
* @package   auto_occasion
* @subpackage actu
* @author    your name
* @copyright 2011 your name
* @link      http://www.yourwebsite.undefined
* @license    All rights reserved
*/

class BoMotCleCtrl extends jController {

    public $pluginParams = array(
                                    '*'=>array('auth.required'=>true,
                                    'jacl2.right'=>'admin.compte.gerer'
                                    )
                            );

    /**
    * Liste des categories des actus
    */
    function index() {
        $rep = $this->getResponse('html');
        $rep->menusActifs = adminHtmlResponse::MENU_ACTU ;

        jClasses::inc('actu~motcleSrv');
        $motcle = motcleSrv::liste();

        $rep->bodyTpl = 'actu~BoMotCleList';
        
        $rep->body->assign('motcle', $motcle);

        return $rep;
    }

    /**
    * Ajout / modif d'une categorie
    */
    function editer() {
        $rep = $this->getResponse('html');
        $rep->menusActifs = adminHtmlResponse::MENU_ACTU ;
        $rep->addJSLink($GLOBALS['gJConfig']->urlengine['basePath'].'design/back/js/jquery.validation.js');

        jClasses::inc('actu~motcleSrv');

        $id = $this->intParam('id', '');
        $motcle   = ($id) ? motcleSrv::chargeParId($id) : motcleSrv::init();

        $rep->body->assign('motcle', $motcle);

        $rep->bodyTpl = 'actu~BoMotCleEdit';
		
        return $rep;
    }

    /**
     * Enregistrer une catégorie
     *
     *
     */
     function sauvegarder() {

        jClasses::inc("actu~motcleSrv");

        $id                = $this->intParam ('id', 0);

        $params = new stdClass();
        $params->ao_motcle_name   = $this->stringParam('motcle_name', '');
        $params->ao_motcle_status = $this->intParam('statut', 0);
        $params->id               = $id;
       
        if ($id) {
            motcleSrv::modifier($params);
        } else {
            motcleSrv::ajouter($params);
        }

        $rep = $this->getResponse('redirect');
        $rep->action = 'actu~BoMotCle:index';
        return $rep;
    }

     /**
    * Supprimer une categorie
    */
    function supprimer() {
        $rep = $this->getResponse('redirect');

        jClasses::inc('actu~motcleSrv');
        $id = $this->intParam('id', '');
        motcleSrv::supprimer($id);

        $rep->action = 'actu~BoMotCle:index';

        return $rep;
    }



}

